<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){

    	$list=M('From')->select();


        // $qrcode=new \Org\Util\Qrcode();
        // $qrcode::png('url:http://www.leipi.org', './test.png', 'L',4, 2); 
        // echo '<img src="/test.png" /--><hr>'; 

    	foreach ($list as $key => $value) {
    		$list[$key]['name']=substr($list[$key]['name'],0,3)."某某";
    	}

    	$count=M('From')->count();
    	
    	$this->assign('count',$count);
    	$this->assign("list",$list);

    	$this->display();
    }




    //报名 
    public function to_sign_up(){

    	if(IS_POST){
    		$f=D('From');
    		if (!$f->create($_POST,1)){ 
    			$result['state']=$f->getError(); 
		    }else{
		         if($f->add()) $result['state']=true;

		    }
    	}
    	$this->ajaxReturn($result);

    }

    public function seach(){
    	if(IS_POST){
            $qrcode=new \Org\Util\Qrcode();
            

    		$list=D('From')->where(array('idcard'=>I('idcard')))->find();

            $qrcode::png('url:http://lybm.lsol.com.cn/?id'.$list['id'], './test.png', 'L',4, 2); 
            
            $list['img']= '/test.png';



    		if($list) $this->ajaxReturn($list);    		
    	}
    	
    }



}